package com.easy.easylibdemo.ui.guidepage;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.easy.easylibdemo.R;
import com.easy.easylibdemo.ui.main.MainActivity;
import com.easylib.base.BaseActivity;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.bingoogolapple.bgabanner.BGABanner;
import cn.bingoogolapple.bgabanner.BGABannerUtil;

public class GuidePageActivity extends BaseActivity {

    @Bind(R.id.banner_background)
    BGABanner bannerBackground;
    @Bind(R.id.banner_foreground)
    BGABanner bannerForeground;
    @Bind(R.id.tv_skip)
    TextView tvSkip;
    @Bind(R.id.btn_enter)
    Button btnEnter;

    @Override
    public int getContentViewId() {
        return R.layout.activity_guide_page;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {

    }

    @Override
    protected void initVariable() {
        bannerForeground.setEnterViewAndSkipView(btnEnter,tvSkip);
    }

    @Override
    protected void processLogic(Bundle savedInstanceState) {
        // 初始化方式1：通过传入数据模型并结合Adapter的方式初始化
        bannerBackground.setAdapter(new BGABanner.Adapter() {
            @Override
            public void fillBannerItem(BGABanner banner, View view, Object model, int position) {
                ((ImageView) view).setImageResource((int) model);
            }
        });
        bannerBackground.setData(Arrays.asList(R.drawable.guide_1, R.drawable.guide_2, R.drawable.guide_3), null);


        // 初始化方式2：通过直接传入视图集合的方式初始化
        List<View> views = new ArrayList<>();
        views.add(BGABannerUtil.getItemImageView(this, R.drawable.guide_foreground_1));
        views.add(BGABannerUtil.getItemImageView(this, R.drawable.guide_foreground_2));
        views.add(BGABannerUtil.getItemImageView(this, R.drawable.guide_foreground_3));
        bannerForeground.setData(views);
    }

    @OnClick({R.id.tv_skip, R.id.btn_enter})
    public void onClick(View view) {
        startActivity(new Intent(mContext, MainActivity.class));
        finish();
    }
}
